/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qdu.dao;

import com.qdu.util.DatabaseUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 *
 * @author 39370
 */
public class AdminLoginDao {

    private static int SUCCESS = 1;
    private static int ERROR = 2;
    private static int SAME = 3;
    public int userLogin(String admin_name, String admin_password) {
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;

        try {
            con = DatabaseUtil.getConnection();
            ps = con.prepareStatement("select * from systemadministrator where admin_name =? and admin_password=?");
            ps.setString(1, admin_name);
            ps.setString(2, admin_password);
            rs = ps.executeQuery();
            if (rs.next()) { // 执行成功
                return this.SUCCESS;
            } else { // 执行失败
                return this.ERROR;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return this.ERROR;
        } finally {
            DatabaseUtil.close(rs, ps, con);
        }

    }
}
